home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / borland / tpwn31.zip / PASCAL.ZIP / DDEML.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-06  |  14KB  |  449 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Turbo Pascal for Windows Run-time Library       }
  5. {       Windows 3.1 API Interface Unit                  }
  6. {                                                       }
  7. {       Copyright (c) 1992 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit ddeml;
  12.  
  13. interface
  14.  
  15. uses WinTypes;
  16.  
  17. type
  18.   HConvList = Longint;
  19.   HConv = Longint;
  20.   HSz = Longint;
  21.   HDDEData = Longint;
  22.  
  23. type
  24.   { the following structure is for use with xtyp_WildConnect processing. }
  25.   PHSZPair = ^THSZPair;
  26.   THSZPair = record
  27.     hszSvc: HSZ;
  28.     hszTopic: HSZ;
  29.   end;
  30.  
  31.   { The following structure is used by DdeConnect() and DdeConnectList()
  32.     and by xtyp_Connect and xtyp_WildConnect callbacks. }
  33.  
  34.   PConvContext = ^TConvContext;
  35.   TConvContext = record
  36.     cb: Word;             { set to sizeof(ConvCOnTEXT) }
  37.     wFlags: Word;         { none currently defined. }
  38.     wCountryID: Word;     { country code for topic/item strings used. }
  39.     iCodePage: Integer;   { codepage used for topic/item strings. }
  40.     dwLangID: Longint;    { language ID for topic/item strings. }
  41.     dwSecurity: Longint;  { Private security code. }
  42.   end;
  43.  
  44. { The following structure is used by DdeQueryConvInfo(): }
  45.  
  46.   PConvInfo = ^TConvInfo;
  47.   TConvInfo = record
  48.     cb: Longint;            { sizeof(CONVINFO)  }
  49.     hUser: Longint;         { user specified field  }
  50.     hConvPartner: HConv;    { hConv on other end or 0 if non-ddemgr partner  }
  51.     hszSvcPartner: HSz;     { app name of partner if obtainable  }
  52.     hszServiceReq: HSz;     { AppName requested for connection  }
  53.     hszTopic: HSz;          { Topic name for conversation  }
  54.     hszItem: HSz;           { transaction item name or NULL if quiescent  }
  55.     wFmt: Word;             { transaction format or NULL if quiescent  }
  56.     wType: Word;            { XTYP_ for current transaction  }
  57.     wStatus: Word;          { ST_ constant for current conversation  }
  58.     wConvst: Word;          { XST_ constant for current transaction  }
  59.     wLastError: Word;       { last transaction error.  }
  60.     hConvList: HConvList;   { parent hConvList if this conversation is in a list }
  61.     ConvCtxt: TConvContext; { conversation context }
  62.   end;
  63.  
  64. const
  65.   { conversation states (usState) }
  66.  
  67.   xst_NULL = 0;                 { quiescent states }
  68.   xst_Incomplete = 1;
  69.   xst_Connected = 2;
  70.   xst_Init1 = 3;                { mid-initiation states }
  71.   xst_Init2 = 4;
  72.   xst_ReqSent = 5;              { active conversation states }
  73.   xst_DataRcvd = 6;
  74.   xst_PokeSent = 7;
  75.   xst_PokeAckRcvd = 8;
  76.   xst_ExecSent = 9;
  77.   xst_ExecAckRcvd = 10;
  78.   xst_AdvSent = 11;
  79.   xst_UnadvSent = 12;
  80.   xst_AdvAckRcvd = 13;
  81.   xst_UnadvAckRcvd = 14;
  82.   xst_AdvDataSent = 15;
  83.   xst_AdvDataAckRcvd = 16;
  84.  
  85.   { used in LOWORD(dwData1) of XTYP_AdvReq callbacks... }
  86.  
  87.   cadv_LateAck = $FFFF;
  88.  
  89.   { conversation status bits (fsStatus) }
  90.  
  91.   st_Connected = $0001;
  92.   st_Advise = $0002;
  93.   st_IsLocal = $0004;
  94.   st_Blocked = $0008;
  95.   st_Client = $0010;
  96.   st_Terminated = $0020;
  97.   st_InList = $0040;
  98.   st_BlockNext = $0080;
  99.   st_IsSelf = $0100;
  100.  
  101.   { DDE constants for wStatus field }
  102.  
  103.   dde_FAck = $8000;
  104.   dde_FBusy = $4000;
  105.   dde_FDeferUpd = $4000;
  106.   dde_FAckReq = $8000;
  107.   dde_FRelease = $2000;
  108.   dde_FRequested = $1000;
  109.   dde_FAckReserved = $3ff0;
  110.   dde_FAdvReserved = $3fff;
  111.   dde_FDatReserved = $4fff;
  112.   dde_FPokReserved = $dfff;
  113.   dde_FAppStatus = $00ff;
  114.   dde_FNotProcessed = $0000;
  115.  
  116.   { message filter hook types }
  117.  
  118.   msgf_DDEMgr = $8001;
  119.  
  120.   { default codepage for windows & old DDE convs. }
  121.  
  122.   cp_WinAnsi = 1004;
  123.  
  124.   { transaction types }
  125.  
  126.   xtypf_NoBlock = $0002; { cbr_Block will not work }
  127.   xtypf_NoData = $0004;  { dde_FDeferUpd }
  128.   xtypf_AckReq = $0008;  { dde_FAckReq }
  129.  
  130.   xclass_Mask = $FC00;
  131.   xclass_Bool = $1000;
  132.   xclass_Data = $2000;
  133.   xclass_Flags = $4000;
  134.   xclass_Notification = $8000;
  135.  
  136.   xtyp_Error = $0000 or xclass_Notification or xtypf_NoBlock;
  137.   xtyp_AdvData = $0010 or xclass_Flags;
  138.   xtyp_AdvReq = $0020 or xclass_Data or xtypf_NoBlock;
  139.   xtyp_AdvStart = $0030 or xclass_Bool;
  140.   xtyp_AdvStop = $0040 or xclass_Notification;
  141.   xtyp_Execute = $0050 or xclass_Flags;
  142.   xtyp_Connect = $0060 or xclass_Bool or xtypf_NoBlock;
  143.   xtyp_Connect_Confirm = $0070 or xclass_Notification or xtypf_NoBlock;
  144.   xtyp_XACT_Complete = $0080 or xclass_Notification;
  145.   xtyp_Poke = $0090 or xclass_Flags;
  146.   xtyp_Register = $00A0 or xclass_Notification or xtypf_NoBlock;
  147.   xtyp_Request = $00B0 or xclass_Data;
  148.   xtyp_Disconnect = $00C0 or xclass_Notification or xtypf_NoBlock;
  149.   xtyp_Unregister = $00D0 or xclass_Notification or xtypf_NoBlock;
  150.   xtyp_WildConnect = $00E0 or xclass_Data or xtypf_NoBlock;
  151.  
  152.   xtyp_Mask = $00F0;
  153.   xtyp_Shift = 4;  { shift to turn xtyp_ into an index }
  154.  
  155.   { Timeout constants }
  156.  
  157.   Timeout_Async =           -1;
  158.  
  159.   { Transaction ID constatnts }
  160.   QID_Sync =                -1;
  161.  
  162.   { public strings used in DDE }
  163.  
  164.   szddesys_Topic = 'System';
  165.   szddesys_Item_Topics = 'Topics';
  166.   szddesys_Item_SysItems = 'SysItems';
  167.   szddesys_Item_RtnMsg = 'ReturnMessage';
  168.   szddesys_Item_Status = 'Status';
  169.   szddesys_Item_Formats = 'Formats';
  170.   szddesys_Item_Help = 'Help';
  171.   szdde_Item_ItemList = 'TopicItemList';
  172.  
  173. type
  174.   { API entry points }
  175.   TCallback = function (CallType, Fmt: Word; Conv: HConv; hsz1, hsz2: HSZ;
  176.     Data: HDDEData; Data1, Data2: Longint): HDDEData;
  177.  
  178. const
  179.   cbr_Block = $ffffffff;
  180.  
  181. { DLL registration functions }
  182.  
  183. function DdeInitialize(var Inst: Longint; Callback: TCallback; Cmd, Res: Longint): Word;
  184.  
  185. const
  186.   { Callback filter flags for use with standard apps. }
  187.  
  188.   cbf_Fail_SelfConnections = $00001000;
  189.   cbf_Fail_Connections = $00002000;
  190.   cbf_Fail_Advises = $00004000;
  191.   cbf_Fail_Executes = $00008000;
  192.   cbf_Fail_Pokes = $00010000;
  193.   cbf_Fail_Requests = $00020000;
  194.   cbf_Fail_AllSrvXActions = $0003f000;
  195.  
  196.   cbf_Skip_Connect_Confirms = $00040000;
  197.   cbf_Skip_Registrations = $00080000;
  198.   cbf_Skip_Unregistrations = $00100000;
  199.   cbf_Skip_Disconnects = $00200000;
  200.   cbf_Skip_AllNotifications = $003c0000;
  201.  
  202.   { Application command flags }
  203.  
  204.   AppCmd_ClientOnly = $00000010;
  205.   AppCmd_FilterInits = $00000020;
  206.   AppCmd_Mask = $00000FF0;
  207.  
  208.   { Application classification flags }
  209.  
  210.   AppClass_Standard = $00000000;
  211.   AppClass_Mask = $0000000F;
  212.  
  213. function DdeUninitialize(Inst: Longint): Bool;
  214.  
  215. { conversation enumeration functions }
  216.  
  217. function DdeConnectList(Inst: Longint; Service, Topic: HSZ;
  218.   ConvList: HConvList; CC: PConvContext): HConvList;
  219. function DdeQueryNextServer(ConvList: HConvList; ConvPrev: HConv): HConv;
  220. function DdeDisconnectList(ConvList: HConvList): Bool;
  221.  
  222. { conversation control functions }
  223.  
  224. function DdeConnect(Inst: Longint; Service, Topic: HSZ;
  225.   CC: PConvContext): HConv;
  226. function DdeDisconnect(Conv: HConv): Bool;
  227. function DdeReconnect(Conv: HConv): HConv;
  228.  
  229. function DdeQueryConvInfo(Conv: HConv; Transaction: Longint;
  230.  ConvInfo: PConvInfo): Word;
  231. function DdeSetUserHandle(Conv: HConv; ID, User: Longint): Bool;
  232.  
  233. function DdeAbandonTransaction(Inst: Longint; Conv: HConv;
  234.   Transaction: Longint): Bool;
  235.  
  236. { app server interface functions }
  237.  
  238. function DdePostAdvise(Inst: Longint; Topic, Item: HSZ): Bool;
  239. function DdeEnableCallback(Inst: Longint; Conv: HConv; Cmd: Word): Bool;
  240.  
  241. const
  242.   ec_EnableAll = 0;
  243.   ec_EnableOne = st_BlockNext;
  244.   ec_Disable = st_Blocked;
  245.   ec_QueryWaiting = 2;
  246.  
  247. function DdeNameService(Inst: Longint; hsz1, hsz2: HSZ;
  248.   Cmd: Word): HDDEData;
  249.  
  250. const
  251.   dns_Register = $0001;
  252.   dns_Unregister = $0002;
  253.   dns_FilterOn = $0004;
  254.   dns_FilterOff = $0008;
  255.  
  256. { app client interface functions }
  257.  
  258. function DdeClientTransaction(Data: Pointer; DataLen: Longint;
  259.   Conv: HConv; Item: HSZ; Fmt, DataType: Word; Timeout: Longint;
  260.   Result: PLongint): HDDEData;
  261.  
  262. { data transfer functions }
  263.  
  264. function DdeCreateDataHandle(Inst: Longint; Src: Pointer;
  265.   cb, Off: Longint; Item: HSZ;